<?php
include 'includes/application_top.inc';
 echo "<pre>";
print_r($_REQUEST);
//header("location:index.php");

$id = $_REQUEST['id'];
$id2= $id;
$id1= $id2;
unset($_REQUEST['id']);
unset($_REQUEST['submit']);
$user_id = $id1;

 
 $Rget= $_REQUEST;
 echo $delSql = "DELETE FROM user_rights_ref WHERE user_id =".$user_id;
	   mysql_query($delSql);
foreach($Rget as $key => $value)
{
	$key."=>".$value."<br>";
	$val= explode("_", $key);
	   $rights_id = $val[1]+1;
	 echo   $query = "INSERT INTO user_rights_ref(id,user_id,rights_id) values(NULL,'$user_id','$rights_id')";
     $result = mysql_query($query)or die ("Error in query: $query " . mysql_error());
	
}
 
	 $successUrl = ROOTURL.'user.php?ac=pmsg';
	header("Location: $successUrl");
?>